﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class EndGameView : IView
{
    public Image[] stars;
    public Text title;
    public Button winBtn;
    public Button failureBtn;

    public void EndGame(float score)
    {
        SetImageColor(score);
        if (score > 0.01f)
        {
            title.text = "胜利";
            winBtn.gameObject.SetActive(true);
            failureBtn.gameObject.SetActive(false);
        }
        else
        {
            title.text = "失败";
            winBtn.gameObject.SetActive(false);
            failureBtn.gameObject.SetActive(true);
        }
        Show();
    }

    void SetImageColor(float score)
    {
        int len = stars.Length;
        if (score > 0.95f)
        {
            stars[0].color = new Color(1, 1, 1);
            stars[1].color = new Color(1, 1, 1);
            stars[2].color = new Color(1, 1, 1);
        }
        else if (score > 0.7f)
        {
            stars[0].color = new Color(1, 1, 1);
            stars[1].color = new Color(1, 1, 1);
            stars[2].color = new Color(0.5f, 0.5f, 0.5f);
        }
        else if (score>0.4f)
        {
            stars[0].color = new Color(1, 1, 1);
            stars[1].color = new Color(0.5f, 0.5f, 0.5f);
            stars[2].color = new Color(0.5f, 0.5f, 0.5f);
        }
        else
        {
            stars[0].color = new Color(0.5f, 0.5f, 0.5f);
            stars[1].color = new Color(0.5f, 0.5f, 0.5f);
            stars[2].color = new Color(0.5f, 0.5f, 0.5f);
        }

 
    }
}
